<template>
  <div class="main">
    <div class="container mt-5">
      <div class="jumbotron">
        <p class="lead">注册成功，我们已经向您的邮箱发送了一封激活邮件，请尽快激活！</p>
        <hr class="my-4">
        <p>
          系统会在
          <span id="seconds" class="text-danger">{{count}}</span>
          秒后自动跳转，您也可以点此<router-link class="text-primary" to="/" replace>链接</router-link>，手动跳转！
        </p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import router from '@/router'

onMounted(() => {
  countDown()
})

let timer = null
const count = ref(10)

const countDown = () => {
  timer = setInterval(() => {
    count.value = count.value - 1
    if (count.value <= 0) {
      clearInterval(timer)
      timer = null
      // 跳转的页面写在此处
      router.replace({path: '/'})
    }
  }, 1000)
}

</script>
